package org.dlx.common;

//队列
public class Queue
{
    private Integer [] _queue;
    private int _size;
    private int _capacity;

    Queue(int capacity){
        _queue = new Integer[capacity];
        _size = 0;
        _capacity = capacity;
    }

    void push(int value) {
        if(_size >= _capacity) {
            int capacity = _capacity * 2;
            Integer [] que = new Integer[capacity * 2];
            System.arraycopy(_queue, 0, que, 0, _size);
            _queue = que;
            _capacity = capacity;
        }
        _queue[_size++] = value;
    }

    Integer pop(){
       if(_size <= 0)
       {
           return null;
       }
       return _queue[--_size];
    }
}
